#!/bin/bash

no_x=true

# Kill gpg-agent on exit.
trap_exit() {
	kill "$(cut -d: -f2 <<< "$GPG_AGENT_INFO")"
}
trap trap_exit EXIT

if $no_x ; then
	unset DISPLAY
fi

# Start gpg-agent.
[[ -z "$GPG_TTY" ]] && export GPG_TTY=$(tty)
[[ -z "$GPG_AGENT_INFO" ]] && eval $(gpg-agent --daemon --default-cache-ttl 10000)

for arg ; do
	echo "signing $arg..."
	gpg -b "$arg" > /dev/null
done
